<?php
	require_once(dirname(dirname(__DIR__)) . '/core.php');


?>
	<div class="ibar_plugin_title"><span class="ibar_plugin_name">购物车<span class="ibar_cart_timer" style="display: inline;"></span></span>
	</div>
	<div class="ibar_plugin_content" style="height: 443px; overflow-y: auto;">
		<div class="ibar_cart_group_container" style="position: relative;">
			<div class="ibar_cart_group ibar_cart_product">
				<div class="ibar_cart_group_header clearfix"><span class="ibar_cart_group_title"><?php echo $site_name;?></span><span class="ibar_cart_group_shop ibar_text_ellipsis"></span><span class="ibar_cart_group_baoyou ibar_pink"></span>
				</div>
				<ul class="ibar_cart_group_items">

				<?php
					if($_SESSION['is_login']){
						$cart = Model('cart')->listCart('db',array('buyer_id'=>$_SESSION['member_id']));
					}
					else{
						$cart = Model('cart')->listCart('cookie',array('buyer_id'=>$_SESSION['member_id']));
					}
					$cart = logic('buy_1')->getGoodsCartList($cart);
					
	
					$count = 0;
					$total = 0;
					foreach($cart as $key => $val){
						if(!Model('goods')->find($val['goods_id'])){
							continue;
						}
						$count += $val['goods_num'];
						$total += $val['goods_price'] * $val['goods_num'];
				?>

				
					<li class="ibar_cart_item clearfix">
						<div class="ibar_cart_item_pic">
							<a target="_blank"  href="/shop/index.php?act=goods&goods_id=<?php echo $val['goods_id']?>">
								<img src="/data/upload/shop/store/goods/<?php echo $val['store_id']?>/<?php echo $val['goods_image']?>" ><span class="ibar_cart_item_tag png"></span>
							</a>
						</div>
						<div class="ibar_cart_item_desc"><span class="ibar_cart_item_name_wrapper"><span class="ibar_cart_item_global">[<?php echo $val['store_name']?>]</span><a class="ibar_cart_item_name" target="_blank"  href="/shop/index.php?act=goods&goods_id=<?php echo $val['goods_id']?>"><?php echo $val['goods_name']?></a>
							</span>
							<div class="ibar_cart_item_sku ibar_text_ellipsis">
							</div>
							<div class="ibar_cart_item_price ibar_pink"><span class="unit_price">￥<?php echo $val['goods_price']?></span><span class="unit_plus"> x </span><span class="ibar_cart_item_count"><?php echo $val['goods_num']?></span>
							</div>
						</div>
					</li>
				<?php		
					}
				?>
				</ul>
			</div>
			<p class="ibar_cart_loading_text">正在为您努力地加载数据！</p>
		</div>
		<div class="ibar_cart_handler ibar_cart_handler_attached" style="display: block; top: 153px;">
			<div class="ibar_cart_handler_header clearfix"><span class="ibar_cart_handler_header_left">共 <span class="ibar_cart_total_quantity ibar_pink"><?php echo $count?></span> 件商品</span><span class="ibar_cart_total_price ibar_pink">￥<?php echo $total;?></span>
			</div><a class="ibar_cart_go_btn" href="/shop/index.php?act=cart" target="_blank">去购物车结算</a>
		</div>
	</div>
